// // 导入gulp，并解构函数
const {src, dest, watch, series} = require('gulp')
const htmlmin = require('gulp-htmlmin')
const autoprefixer = require('gulp-autoprefixer')
const cleanCss = require('gulp-clean-css')
const babel = require('gulp-babel')
const uglify = require('gulp-uglify')
const webserver = require('gulp-webserver')
// 将所有任务定义好
// 压缩html
function compressHTML(cb){
    src('./src/*.html')
    .pipe(htmlmin({
        collapseWhitespace: true
    }))
    .pipe(dest('./dist'))
    cb()
}
// 复制图片
function cloneIMG(cb){
    // src('./src/images/*.*')
    src(['./src/images/*.jpg', './src/images/*.png', './src/images/*.gif'])
    .pipe(dest('./dist/images'))
    cb()
}
// 处理js
function handlerJS(cb){
    // src('./src/js/*.js')
    // src('./src/js/validation/*.js')
    // src('./src/js/validation/localization/*.js')
    src('./src/js/layer/*.*')

    .pipe(babel({
        presets: ['es2015']
    }))
    .pipe(uglify())
    // .pipe(dest('./dist/js'))
    // .pipe(dest('./dist/js/validation'))
    // .pipe(dest('./dist/js/validation/localization'))
    .pipe(dest('./dist/js/layer'))
    cb()
}
// 处理css
function handlerCSS(cb){
    src('./src/css/*.css')
    .pipe(autoprefixer()) // 需要加参数
    .pipe(cleanCss())
    .pipe(dest('./dist/css'))
    cb()
}

// 导出任务
exports.default = handlerCSS